<?php

/*
 * Copyright by Sygma Media Inovasi Ω2013
 * 
 * Lead Programmer : Sony K Wibisono,S.Si,M.T.I
 * E-mail : sony@sonywibisono.com
 * 
 * Designer : Mr. Agus
 * 
 */
class Menus {
    var $id;
var $caption;
var $tooltip;
var $url_link;
var $parent_id;
var $content_id;
var $visible;


    function open(){
        global $db;
        $sql="select * from menus where id=$id";
        $row=$db->fetch_row($sql);
        if (!empty($row)){
            extract($row);
            $this->caption=$caption;
$this->tooltip=$tooltip;
$this->url_link=$url_link;
$this->parent_id=$parent_id;
$this->content_id=$content_id;
$this->visible=$visible;

        }
    }

    function openAll(){
        $sql="select * from menus order by id asc";
        $result=$db->query($sql);
        return $db->fetch_array($result);
        
    }

    function insert(){
    global $db;
    $sql="insert into menus values (null,'{$this->caption}','{$this->tooltip}',
        '{$this->url_link}','{$this->parent_id}','{$this->content_id}','{$this->visible}')";
    $db->query($sql);
    return mysql_insert_id();
    }

    function update(){
        global $db;
        $sql="update menus set caption='{$this->caption}',
tooltip='{$this->tooltip}',url_link='{$this->url_link}',
parent_id='{$this->parent_id}',content_id='{$this->content_id}',
visible='{$this->visible}' where id=".$this->id;
        $db->query($sql);
    }

    function delete(){
        global $db;
        $sql="delete from menus where id=".$this->id;
        $db->query($sql);
    }

}
?>
